<?php
	// You need to call define the function at function_check_table.php

	if(SETTING_CHECK_TABLES == 1)
	{
		$db_status = check_database_status(1);	// return $db_status
		if($db_status == 1)
		{
	
			$msg_result = "CREATE TABLES : <br />";
			$result = 0;
			
			$msg_result .= "<table border='0' cellpadding='0' cellspacing='0'><tr><th style='width:30px;'></th><th></th><th></th><th></th></tr>";
			
			// Auto create Ms_user if not exists
			$chknum = 1; $chkname = "User";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Tr_Log if not exists
			$chknum = 2; $chkname = "Log";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_Module if not exists
			$chknum = 3; $chkname = "Module";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_Module_Sub if not exists
			$chknum = 4; $chkname = "Sub Module";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_Setting if not exists
			$chknum = 5; $chkname = "Setting";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_Status if not exists
			$chknum = 6; $chkname = "Status";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_Module_Admin if not exists
			$chknum = 7; $chkname = "Admin Module";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_User_Group if not exists
			$chknum = 8; $chkname = "User Group";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Tr_Login_Punishment if not exists
			$chknum = 9; $chkname = "Login Punishment";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_Module_Group_Privilege if not exists
			$chknum = 10; $chkname = "Module Group Privilege";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Ms_Module_Sub_2 if not exists
			// $chknum = 11; $chkname = "Sub Module 2";
			// $result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Image if not exists
			$chknum = 12; $chkname = "Image";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			// Auto create Component if not exists
			$chknum = 13; $chkname = "Component";
			$result = check_tables($chknum); $msg_result .= "<tr><td>#".$chknum."</td><td>&nbsp;:&nbsp;</td>";if($result == 1){$msg_result .= "<td>".$chkname." </td><td><span style='color:green;'>&nbsp;SUCCESS&nbsp;</span></td>";}else{$msg_result .= "<td><span style='color:red;'>FAILED</span></td>";}$msg_result .= "</tr>";
			
			
			$msg_result .= "</table>";
			echo $msg_result;
		}
		else
		{
			echo "<span style='color:red;'>DATABASE IS NOT EXIST !!</span>";
		}
	}
	else
	{
		echo "<span style='color:red;'>ERROR CANNOT CHECK TABLES, CHECK TABLES IS NOT ALLOWED !!</span>";
	}
?>